#include <stdio.h>
#include <string.h>
int gcd(int a,int b)
{
    int r;
    while(b)
    {
        r = a%b;
        a = b;
        b = r;
    }
    return a;
}
int main()
{
    char ch[1001];
    int len,i,g,k,f,j,high,m;     
    while(scanf(" %s",&ch)!=EOF)
    {
        int flag[900][27]={0};
        int sign[28]={0};
        char c[900][900]={0};
        high = k = 0;
        int num[27]={0};
        len = strlen(ch);
        for(i=0;i<len;i++)    num[ch[i]-'A']++;
        for(i=0,f=0;i<27;i++)
        {
            if(num[i]&&k==0)
            {
                g = num[i];
                sign[f] = num[i];
                k=1;
                f++;
            }
            else if(num[i]&&k==1)
            {
                sign[f] = num[i];
                g = gcd(num[i],g);
                f++;
            } 
        }
        for(i=0;i<f;i++)
        {
            
            sign[i]=sign[i]/g;
            //printf("sign = %d\n",sign[i]);
            if(sign[i]>high)
            {
                high = sign[i];
                //printf("-------\n");
            }
            for(j=0;j<sign[i];j++) flag[j][i]=1;
        }
        for(i=high-1;i>=0;i--)
        {
        //    printf("-------\n");
            for(j=0;j<f;j++)
            {
                if(flag[i][j]) c[i][j]='*';
                else c[i][j]=' '; 
            }
            for(j=f-1;j>=0;j--)
            {
                if(!flag[i][j]) c[i][j]='\0';
                else break;
            }
        }
        for(i=high-1;i>=0;i--)
        {
            puts(c[i]);
        }
        for(m=0,i=0;m<f;i++)
        {
            if(num[i])
            {
                printf("%c",i+'A');    
                m++;
            } 
        }
        printf("\n\n");
    }
}
